/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lily
 * Date: 2024-11-01
 * Time: 19:53
 */
public class test_3 {
    int[] dp = new int[1010];
    public int knapsack (int V, int n, int[][] vw)
    {
        for(int i = 0; i < n; i++)
        {
            for(int j = V; j >= vw[i][0]; j--)
            {
                dp[j] = Math.max(dp[j], dp[j - vw[i][0]] + vw[i][1]);
            }
        }
        return dp[V];
    }
}
